/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import entities.Shift;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author viev
 */
public class ViewTimeSlotTableModel extends AbstractTableModel {
    private ArrayList<Shift> list;

    public ViewTimeSlotTableModel() {
        list = new ArrayList<Shift>();
    }

    public ViewTimeSlotTableModel(ArrayList<Shift> list) {
        this.list = list;
    }

    @Override
    public int getRowCount() {
        return list.size();
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Shift shift = list.get(rowIndex);
        Date startTime = shift.getStartTime();
        Date endTime = shift.getEndTime();
        switch (columnIndex) {
            case 0:
                return shift.getShiftID();
            case 1:
                return shift.getName();
            case 2:
                return startTime;
            case 3:
                return endTime;
            default:
                return null;
        }
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return Integer.class;
            case 1:
                return String.class;
            case 2:
                return String.class;
            case 3:
                return String.class;
            default:
                return null;
        }
    }

    @Override
    public String getColumnName(int column) {
        switch (column) {
            case 0:
                return "ID";
            case 1:
                return "Shift";
            case 2:
                return "Begin";
            case 3:
                return "End";
            default:
                return null;
        }
    }
}
